/**
 * @param id - 班级 id
 */
interface FetchChatListAPIParams {
  id: string
  page: string
  limit: string
}

interface FetchChatListAPIResData {
  code: number
  msg: string
  time: string
  data: {
    data: Chat[]
    current_page: number
    total: number
    per_page: number
    last_page: number
    class_info: {
      title: string
      images: string
    }
  }
}

/**
 * @description 分页获取最近聊天列表，从班级主页的“班级交流”入口进入
 */
export function fetchChatListAPI(params: FetchChatListAPIParams, token: string) {
  return httpInstance.get<FetchChatListAPIResData, FetchChatListAPIParams>(
    '/api/message/messagelist',
    { params, headers: { token } },
  )
}
